package com.bd.scm.module;

/**
 * @author YH
 * @version 1.0
 * @date 2020/9/18 15:56
 */
import com.bd.scm.module.utils.SendEmailUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class SendHtmlTemplateMail {

    public static void main(String[] args) throws Exception {
        // 读取html模板
        String html = SendEmailUtil.readHtmlToString("mailTemplate.html");

        // 写入模板内容
        Document doc = Jsoup.parse(html);
        doc.getElementById("title").html("java 邮件发送测试");
        doc.getElementById("content").html("<a href=\"https://www.baidu.com/\">审批地址</a>");
        String result = doc.toString();

        //邮件服务地址
        String mailHost = "smtp.163.com";
        //发件人
        String fromMail = "yu_0hong@163.com";
        //发件人名
        String fromName = "小灰";
        //发件人密码
        String fromMailPwd = "";
        //收件人，多个用英文逗号分隔
        String toMails = "623533270@qq.com";
        //邮件标题
        String mailTitle = "审批";
        //邮件内容
        String mailContent = result;

        // 发送邮件
        SendEmailUtil.sendMail(mailHost, fromMail, fromName, fromMailPwd, toMails, mailTitle, mailContent);
    }
}
